<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<div id="page-content">
    <div class="row">

        <div class="col-lg-12">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">付款申请</h3>
                </div>
                <div class="panel-body">
                    <div class="form-inline">
                        <div class="row">
                            <div class="col-sm-12 table-toolbar-left">
                                <btn id="btn_add_pay" class="btn btn-primary btn-sm" ${isStart}>
                                    <i class="ti-plus"> </i> 新建付款申请
                                </btn>
                            </div>
                        </div>
                    </div>
                    <div class="table-jqgrid">
                        <table id="pay_table"></table>
                        <div id="pay_page"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>

    $(function(){

        init_grid_pay();

    });

    function init_grid_pay() {
        var viewType = "${viewtype}";
        if(viewType == 1){
            __init_jqgrid('pay_table', 'pay_page',
                '<%=path%>/com/pay/list?viewtype=${viewtype}',
                ['付款金额',"付款事由","支付日期","支付对象",'申请人',"申请日期","审批人","操作","id"],
                [
                    {name:'amount',index:'amount', width:80,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                    {name:'type',index:'type', width:150,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                    {name:'payDate',index:'payDate',sortable:true,search:true,width:120, searchoptions: {sopt: ['cn']}},
                    {name:'object',index:'object',sortable:true,search:true,width:200, searchoptions: {sopt: ['cn']}},
                    {name:'creater',index:'creater',sortable:true,search:true,width:80, searchoptions: {sopt: ['cn']}},
                    {name:'createTime',index:'createTime',sortable:true,search:true,width:120, searchoptions: {sopt: ['cn']}},
                    {name:'editor',index:'editor',sortable:true,search:true,width:80, searchoptions: {sopt: ['cn']}},
                    {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
                    {name:'id',index:'id',search:false,hidden:true}
                ],
                true,true
            );
        }else{
            __init_jqgrid('pay_table', 'pay_page',
                '<%=path%>/com/pay/list?viewtype=${viewtype}',
                ['付款金额',"付款事由","支付日期","支付对象",'申请人',"审批日期","操作","id"],
                [
                    {name:'amount',index:'amount', width:80,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                    {name:'type',index:'type', width:150,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                    {name:'payDate',index:'payDate',sortable:true,search:true,width:120, searchoptions: {sopt: ['cn']}},
                    {name:'object',index:'object',sortable:true,search:true,width:200, searchoptions: {sopt: ['cn']}},
                    {name:'creater',index:'creater',sortable:true,search:true,width:80, searchoptions: {sopt: ['cn']}},
                    {name:'modifyTime',index:'modifyTime',sortable:true,search:true,width:120, searchoptions: {sopt: ['cn']}},
                    {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
                    {name:'id',index:'id',search:false,hidden:true}
                ],
                true,true
            );
        }


    }


    function actFormat(cellvalue, options, rowObject){
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_pay_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button>';
        return cellvalue;
    }

    function fn_pay_read(id) {
        loadURL('<%=path%>/com/pay/read?keyId='+id+'&viewtype=${viewtype}', $('#page-content'));
    }

    $("#btn_add_pay").click(function(){
        loadURL('<%=path%>/com/pay/input', $('#page-content'));
    });
</script>